<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>车服租赁系统运营管理后台</title>
    <meta name="description" content="车服租赁系统运营管理后台">
    <meta name="keywords" content="车服租赁系统运营管理后台">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">

    <link rel="stylesheet" href="/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/style.css">
    <!-- 引入组件库 -->
    <script src="/js/vue.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script src="/js/axios-0.18.0.js"></script>
    <script src="/js/request.js"></script>
    <style type="text/css">
        .el-main {
            top: 70px;
            bottom: 0px;
            left: 200px;
            right: 10px;
            padding: 0;
        }
        iframe{
            position: absolute;
        }
    </style>
</head>
<body class="hold-transition skin-purple sidebar-mini">
    <div id="app">
        <!--顶层布局容器-->
        <el-container height="100%">
            <!--头部布局容器-->
            <el-header class="main-header" style="height:70px;">
                <!--导航栏标签-->
                <nav class="navbar navbar-static-top" :class=''>
                    <!-- Logo -->
                    <a href="#" class="logo" style="text-align:center">
                        <span class="logo-lg">
                            <img src="/img/logo.png" width="170px" height="40px">
                        </span>
                    </a>
                    <!--导航栏右侧菜单-->
                    <div class="right-menu">
                        <!--下拉菜单-->
                        <el-dropdown class="avatar-container right-menu-item" trigger="click">
                            <!--头像-->
                            <div class="avatar-wrapper">
                                <img src="/img/user3-128x128.jpg" style="width: 45px;height: 45px;" class="user-avatar">
                                {{this.loginUser.username}}
                            </div>
                            <!--下拉菜单-->
                            <el-dropdown-menu slot="dropdown">
                                <!--下拉菜单项-->
                                <el-dropdown-item divided>
                                    <span style="display:block;">修改密码</span>
                                </el-dropdown-item>
                                <el-dropdown-item divided>
                                            <span style="display:block;">
                                                <a href="#" @click="logout">退出</a>
                                            </span>
                                </el-dropdown-item>
                            </el-dropdown-menu>
                        </el-dropdown>
                    </div>
                </nav>
            </el-header>
            <!--左侧菜单-->
            <el-aside width="200px">
                <el-menu>
                    <!--一个elsubmenu相当于一个二级菜单-->
                    <!--
                        v-for：vue里面的循环指令，相当于java里面的增强for循环
                    -->
                    <el-submenu v-for="menu in menuList" :index="menu.path">
                        <template slot="title">
                            <i class="fa" :class="menu.icon"></i>
                            {{menu.title}}
                        </template>
                        <template v-for="child in menu.children">
                            <el-menu-item :index="child.path">
                                <a :href="child.linkUrl" target="right">{{child.title}}</a>
                            </el-menu-item>
                        </template>
                    </el-submenu>
                </el-menu>
            </el-aside>
            <!--右侧主区域-->
            <el-main>
                <iframe name="right" class="el-main" width="87%"  height="650px"
                        frameborder="0"></iframe>
            </el-main>
        </el-container>
    </div>
</body>
<script>
    new Vue({
        el: '#app',
        data() {
            return{
                /*菜单列表数据模型*/
                menuList:[],
                /*登录用户的详细信息*/
                loginUser:{}
            }
        },
        created() {
            this.queryMenuByUsername();
            this.userInfo();
        },
        methods: {
            queryMenuByUsername() {
                request({
                    method: "get",
                    url: "/menu"
                }).then(data => {
                    this.menuList = data.data.data;
                    console.log("获取到的菜单列表: ", this.menuList)
                })
            },
            logout() {

            },
            /*登录成功以后从后台查询用户其他信息*/
            userInfo() {
                request({
                    method: "get",
                    url: "/userinfo"
                }).then(data => {
                    this.loginUser = data.data.data;
                    console.log("登录成功以后查询的用户详细信息: ", this.loginUser);
                })
            }
        }
    });
</script>
</html>
